package com.wc.AlgoOJ_homework.aloj模拟赛.迷宫;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/5/30 23:50
 * @description http://43.138.190.70:8888/p/LQ1339?tid=6655c0f9c056ef947a21997d
 * 细节
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 2010, M = N * N, idx = 1;
    static int[] h = new int[M], e = new int[N << 1], ne = new int[N << 1];
    static int[][] g = new int[N][N];
    static int[] dx = new int[]{-1, 1, 0, 0}, dy = new int[]{0, 0, 1, -1};
    static boolean[][] st = new boolean[N][N];
    static int[] q = new int[N * N];
    static int n, m;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        while (m-- > 0) {
            int x1 = sc.nextInt() - 1, y1 = sc.nextInt() - 1;
            int x2 = sc.nextInt() - 1, y2 = sc.nextInt() - 1;
            int a = x1 * n + y1, b = x2 * n + y2;
            add(a, b);
            add(b, a);
        }
        bfs();
        double sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                sum += g[i][j];
            }
        }
        out.printf("%.2f\n", sum / (n * n));
        out.flush();
    }

    static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }

    static void bfs() {
        int hh = 1, tt = 0;
        q[++tt] = (n - 1) * n + n - 1;
        st[n - 1][n - 1] = true;
        while (hh <= tt) {
            int t = q[hh++];
            int x = t / n, y = t % n;
            // 传送门
            for (int i = h[t]; i > 0; i = ne[i]) {
                int j = e[i];
                int nx = j / n, ny = j % n;
                if (!st[nx][ny]) {
                    g[nx][ny] = g[x][y] + 1;
                    st[nx][ny] = true;
                    q[++tt] = j;
                }
            }

            // 上下左右
            for (int i = 0; i < 4; i++) {
                int nx = x + dx[i], ny = y + dy[i];
                if (nx >= 0 && nx < n && ny >= 0 && ny < n && !st[nx][ny]) {
                    st[nx][ny] = true;
                    g[nx][ny] = g[x][y] + 1;
                    q[++tt] = nx * n + ny;
                }
            }
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
